(function(){

	LibreGE.node.Test3DParticle = function(){
		
		var img = new Image();
		img.src = 'texture.png';
		var pMatrix = mat4.identity();
		var mvMatrix = mat4.identity();
		mat4.translate(mvMatrix, [0, 0, -1]);
	    var texture = null;
	    var vertices = new Float32Array([
	        0.0,  1.0,  0.0,
			-1.0, -1.0,  0.0,
			1.0, -1.0,  0.0
	    ]);
	    var colors = new Float32Array([
			1.0, 0.0, 0.0, 1.0,
			0.0, 1.0, 0.0, 1.0,
			0.0, 0.0, 1.0, 1.0
	    ]);
	    var coords = new Float32Array([
			0.5, 0.0,
			0.0, 1.0,
			1.0, 1.0			
		]);
	    var color = new Float32Array([0.0, 0.0, 0.0, 1.0]);
	    var program = LibreGE.program.simpleTexture();
//	    var program = LibreGE.program.simpleColor();
	    
		var node = new LibreGE.node.Node(); 
		node.draw = function(context, ge){
			var gl = context;
			if(!this.init){
				
				texture = LibreGE.Program.getTexture(gl, img);

				program.initialize(gl);
				program.use(gl);
				program.bindData(gl, pMatrix, mvMatrix, vertices, coords, 1.0, texture);
//				program.bindData(gl, pMatrix, mvMatrix, vertices, color);
				
				setTimeout(function(){
					program.finalize(gl);
					color[0] = 1.0;
					program.bindData(gl, pMatrix, mvMatrix, vertices, color);
				}, 1000);
				this.init = true;
			}else{
		        gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);			
		        gl.drawArrays(gl.TRIANGLES, 0, 3);
			}
		};
		
		return node;
	};

})();


